<template>
  <a-modal
    :title="title"
    :width="700"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
    cancelText="关闭"
    wrapClassName="ant-modal-cust-warp"
    style="top: 5%; height: 90%; overflow-y: hidden"
  >
    <a-spin :spinning="confirmLoading">
      <div class="reportList">
        <div class="list-wrap">
          <div class="li" v-for="(item, index) in evenList[0].list" :key="index">
            <!-- <a :href="'#item-' + item.id" @click="useList(item)" ></a> -->
            <!-- <img :src="getAvatar(item.image)" :preview="evenList[0].role"/> -->
            <img :src="getAvatar(item.image)"/>
          </div>
        </div>
      </div>
    </a-spin>
  </a-modal>
</template>

<script>
import { addRole, editRole, duplicateCheck } from '@/api/api'
import { getFileAccessHttpUrl, getAction } from '@/api/manage'
export default {
  name: 'RoleModal',
  data() {
    return {
      // listData:[
      //   {content:' 识和能力，并帮助学生提高汉语口头表达能力。我的第一个要求是需要读、写作等方面的知识和能力，并帮助学生提高汉语口头表达能力。我的第一个要求是需要有人帮我写一篇作文。'},
      //   {content:' 读、写作等方面的知识和能力，并帮助学生提高汉语口头表达能力。我的第一个要求是需要有人帮我写一篇作文。'},
      // ],
      disableSubmit: false,
      newMessage: '',
      title: '操作',
      visible: false,
      roleDisabled: false,
      model: {},
      newList: [
        { role: 'user', list: [{}] },
        { role: 'assistant', list: [{}] },
      ],
      confirmLoading: false,
      arrow_r: '111111111111',

    }
  },
  props: {
    listData: {
      type: Array,
    },
  },
  computed: {
    evenList: function () {
      let list = this.listData
      this.newList[0].list = list
      var array = this.newList
      // let key = 'role'
      // var keysArr = list.map((item) => item[key])
      // var keys = [...new Set(keysArr)]
      // var newList = keys.map((item) => {
      //   return {
      //     [key]: item,
      //     list: list.filter((i) => i[key] == item),
      //   }
      // })
      // console.log('newList', newList)
      // var array = newList.length  === 0 || newList[1] === undefined ? this.copyData[1] : newList[1]
      console.log('array',array)
      return array
    },
  },
  mounted() {
    //
    console.log('listData', this.listData)
  },
  methods: {
    getAvatar(img) {
      return getFileAccessHttpUrl(img)
    },
    //使用聊天弹框语言
    useList(id) {
      this.visible = false
      this.$emit('ok', id)
    },
    //查询
    sendMessage() {
      if (this.newMessage.trim() !== '') {
      }
    },
    // 点击展开折叠菜单事件
    showToggle(item, ind) {
      this.menuList.forEach((i) => {
        // 判断如果数据中的menuList[i]的show属性不等于当前数据的isSubShow属性那么menuList[i]等于false
        if (i.isSubShow !== this.menuList[ind].isSubShow) {
          i.isSubShow = false
        }
      })
      item.isSubShow = !item.isSubShow
    },
    add() {
      this.edit(this.modelDefault)
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
      //编辑页面禁止修改角色编码
      if (this.model.id) {
        this.roleDisabled = true
      } else {
        this.roleDisabled = false
      }
    },
    close() {
      // this.$refs.form.clearValidate()
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      this.close()
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>

<style lang="less" scoped>
@px: 4;

.reportList {
  float: left;
  width: 100%;
  padding: 20px;
  height: 100%;
  .list-wrap {
    height: 400px;
    overflow: hidden auto;
    .li {
      cursor: pointer;
      padding: 12px 20px;
      margin-bottom: 2px;
      border-radius: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      float: left;
      a {
        float: left;
        color: black;
        width: 100%;
      }
    }
    .li:hover {
      color: #7a46fc;
      background: #f2edff;
    }
    img {
      width: 160px;
      height: 160px;
    }
  }
}
</style>